<!DOCTYPE html>



  


<html class="theme-next mist use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />





  <link rel="alternate" href="/atom.xml" title="yampery" type="application/atom+xml" />






<meta name="description" content="环境准备准备节点 node1: yum源，httpd，mariadb和java8环境 node2: java8环境 node3: java8环境 node4: java8环境  将主机名-ip映射配置到每个节点 /etc/hosts  127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1">
<meta property="og:type" content="article">
<meta property="og:title" content="ambari搭建大数据平台">
<meta property="og:url" content="https://yampery.gitee.io/2019/02/25/ambari/index.html">
<meta property="og:site_name" content="yampery">
<meta property="og:description" content="环境准备准备节点 node1: yum源，httpd，mariadb和java8环境 node2: java8环境 node3: java8环境 node4: java8环境  将主机名-ip映射配置到每个节点 /etc/hosts  127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://i.imgur.com/Qw3fYfC.png">
<meta property="og:image" content="https://i.imgur.com/meXkLyF.png">
<meta property="og:image" content="https://i.imgur.com/6NR59vZ.png">
<meta property="og:image" content="https://i.imgur.com/namV8ua.png">
<meta property="og:image" content="https://i.imgur.com/AmndrgO.png">
<meta property="og:updated_time" content="2018-07-16T09:20:08.802Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ambari搭建大数据平台">
<meta name="twitter:description" content="环境准备准备节点 node1: yum源，httpd，mariadb和java8环境 node2: java8环境 node3: java8环境 node4: java8环境  将主机名-ip映射配置到每个节点 /etc/hosts  127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1">
<meta name="twitter:image" content="https://i.imgur.com/Qw3fYfC.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Mist',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://yampery.gitee.io/2019/02/25/ambari/"/>





  <title>ambari搭建大数据平台 | yampery</title>
  








  <link href='//fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">yampery</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">天尽头，回眸望红尘</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://yampery.gitee.io/2019/02/25/ambari/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="yampery">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="yampery">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">ambari搭建大数据平台</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-02-25T11:05:38+08:00">
                2019-02-25
              </time>
            

            

            
          </span>

          

          
            
          

          
          
             <span id="/2019/02/25/ambari/" class="leancloud_visitors" data-flag-title="ambari搭建大数据平台">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  2.2k 字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  11 分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="环境准备"><a href="#环境准备" class="headerlink" title="环境准备"></a>环境准备</h1><h2 id="准备节点"><a href="#准备节点" class="headerlink" title="准备节点"></a>准备节点</h2><ul>
<li>node1: yum源，httpd，mariadb和java8环境</li>
<li>node2: java8环境</li>
<li>node3: java8环境</li>
<li>node4: java8环境</li>
</ul>
<p>将主机名-ip映射配置到每个节点</p>
<pre><code>/etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.107.74 node1
192.168.107.83 node2
192.168.107.105 node3
192.168.107.131 node4
</code></pre><h2 id="免秘钥登录"><a href="#免秘钥登录" class="headerlink" title="免秘钥登录"></a>免秘钥登录</h2><ol>
<li><p>在每个节点上生成ssh秘钥</p>
 <figure class="highlight plain"><figcaption><span>-t rsa -P '' -f ~/.ssh/id_rsa</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
<li><p>将主节点公钥依次发送到其余节点</p>
 <figure class="highlight plain"><figcaption><span>.ssh/id_rsa.pub root@node2:~/</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
<li><p>将主节点上的公钥追加到其他节点~/.ssh/authorized_keys</p>
 <figure class="highlight plain"><figcaption><span>cat id_rsa.pub >> ~/.ssh/authorized_keys && cat id_rsa.pub >> ~/.ssh/authorized_keys && chmod 0600 ~/.ssh/authorized_keys</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
<li><p>测试免秘钥登录</p>
 <figure class="highlight plain"><figcaption><span>root@node2</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
</ol>
<h2 id="关闭Selinux和防火墙"><a href="#关闭Selinux和防火墙" class="headerlink" title="关闭Selinux和防火墙"></a>关闭Selinux和防火墙</h2><pre><code>vim /etc/sysconfig/selinux
selinux=disalbed

systemctl stop firewalld
systemctl disable firewalld
</code></pre><h2 id="时间同步"><a href="#时间同步" class="headerlink" title="时间同步"></a>时间同步</h2><blockquote>
<p>如果节点上时间不正确，则：</p>
</blockquote>
<pre><code># 安装ntpdate工具 
yum -y install ntp ntpdate  
# 设置系统时间与网络时间同步   
ntpdate cn.pool.ntp.org
# 将系统时间写入硬件时间
hwclock --systohc
</code></pre><h3 id="安装nscd"><a href="#安装nscd" class="headerlink" title="安装nscd"></a>安装nscd</h3><blockquote>
<p>由于ambari server和client之间要通信，为了减轻dns压力使用nscd缓存</p>
</blockquote>
<pre><code>yum install -y nscd
systemctl enable nscd &amp;&amp; systemctl start nscd
</code></pre><h2 id="安装jdk"><a href="#安装jdk" class="headerlink" title="安装jdk"></a>安装jdk</h2><pre><code>略
</code></pre><h2 id="配置本地仓库"><a href="#配置本地仓库" class="headerlink" title="配置本地仓库"></a>配置本地仓库</h2><ol>
<li><p>安装yum-utils</p>
 <figure class="highlight plain"><figcaption><span>install yum-utils createrepo</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
<li><p>创建HTTP服务</p>
 <figure class="highlight plain"><figcaption><span>install httpd -y</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
<li><p>下载源，根据自己想要的版本更改</p>
<p> 将repo文件放在/etc/yum.repos.d/ 目录下，等会配置，tgz文件放在http服务器下：/var/www/html下</p>
<pre><code>wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.1.0/ambari.repo
wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.4.0/hdp.repo
wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.1.0/ambari-2.6.1.0-centos7.tar.gz
wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
wget http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.4.0/HDP-GPL-2.6.4.0-centos7-rpm.tar.gz
wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.4.0/HDP-2.6.4.0-centos7-rpm.tar.gz
</code></pre><p> 将以上tgz文件解压在/var/www/html下</p>
</li>
<li><p>启动httpd测试访问</p>
<p> systemctl start httpd
 访问：<a href="http://node1/ambari" target="_blank" rel="noopener">http://node1/ambari</a>, <a href="http://node1/HDP" target="_blank" rel="noopener">http://node1/HDP</a>, <a href="http://node1/HDP-UTILS.." target="_blank" rel="noopener">http://node1/HDP-UTILS..</a>.</p>
</li>
<li><p>配置yum源</p>
<ul>
<li><p>更改/etc/yum.repos.d/下刚才下载的文件，将源路径指向node1</p>
<p>vi /etc/yum.repos.d/hdp.repo</p>
<p>  [HDP-2.6.4.0]
  name=HDP Version - HDP-2.6.4.0
  baseurl=<a href="http://node1/HDP/centos7/2.6.4.0-91" target="_blank" rel="noopener">http://node1/HDP/centos7/2.6.4.0-91</a>
  gpgcheck=1
  gpgkey=<a href="http://node1/HDP/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="noopener">http://node1/HDP/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a>
  enabled=1
  priority=1</p>
<p>  [HDP-UTILS-1.1.0.22]
  name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
  baseurl=<a href="http://node1/HDP-UTILS/centos7/1.1.0.22" target="_blank" rel="noopener">http://node1/HDP-UTILS/centos7/1.1.0.22</a>
  gpgcheck=1
  gpgkey=<a href="http://node1/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="noopener">http://node1/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a>
  enabled=1
  priority=1</p>
<p>  [HDP-GPL-2.6.4.0]
  name=HDP-GPL Version - HDP-GPL-2.6.4.0
  baseurl=<a href="http://node1/HDP-GPL/centos7/2.6.4.0-91" target="_blank" rel="noopener">http://node1/HDP-GPL/centos7/2.6.4.0-91</a>
  gpgcheck=1
  gpgkey=<a href="http://node1/HDP-GPL/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="noopener">http://node1/HDP-GPL/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a>
  enabled=1
  priority=1</p>
<p>vi /etc/yum.repos.d/hdp.repo</p>
<p>  [ambari-2.6.1.0]
  name=ambari Version - ambari-2.6.1.0
  baseurl=<a href="http://node1/ambari/centos7/2.6.1.0-143" target="_blank" rel="noopener">http://node1/ambari/centos7/2.6.1.0-143</a>
  gpgcheck=1
  gpgkey=<a href="http://node1/ambari/centos7/2.6.1.0-143/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins" target="_blank" rel="noopener">http://node1/ambari/centos7/2.6.1.0-143/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins</a>
  enabled=1
  priority=1</p>
</li>
<li><p>缓存yum源</p>
<figure class="highlight plain"><figcaption><span>clean all && yum makecache fast</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ol>
<h2 id="安装ambar"><a href="#安装ambar" class="headerlink" title="安装ambar"></a>安装ambar</h2><h3 id="安装mariadb"><a href="#安装mariadb" class="headerlink" title="安装mariadb"></a>安装mariadb</h3><pre><code>yum install mariadb-server -y
systemctl start mariadb
mysql_secure_installation # 直接确定，然后设置root密码

# 创建数据库：

MariaDB [(none)]&gt; create database ambari default character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]&gt; grant all on ambari.* to ambari@localhost identified by &apos;ambari&apos;;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]&gt; grant all on ambari.* to ambari@&apos;%&apos; identified by &apos;ambari&apos;;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]&gt; create database hive default character set utf8;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]&gt; grant all on hive.* to hive@localhost identified by &apos;ambari&apos;;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]&gt; grant all on hive.* to hive@&apos;%&apos; identified by &apos;ambari&apos;;
</code></pre><h3 id="安装ambari-server"><a href="#安装ambari-server" class="headerlink" title="安装ambari-server"></a>安装ambari-server</h3><pre><code>yum install ambari-server -y
ambari-server setup
</code></pre><blockquote>
<p>安装过程中要选择数据库，如果出现如下警告：按照提示放入jdbc驱动jar包，并配置路径即可
WARNING: Before starting Ambari Server, you must copy the MySQL JDBC driver JAR file to /usr/&gt; share/java and set property “server.jdbc.driver.path=[path/to/custom_jdbc_driver]” in ambari.properties.</p>
</blockquote>
<pre><code>vim /etc/ambari-server/conf/ambari.properties 
server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.34.jar

Using python  /usr/bin/python
Setup ambari-server
Checking SELinux...
SELinux status is &apos;enabled&apos;
SELinux mode is &apos;permissive&apos;
WARNING: SELinux is set to &apos;permissive&apos; mode and temporarily disabled.
OK to continue [y/n] (y)? y
Customize user account for ambari-server daemon [y/n] (n)? y
Enter user account for ambari-server daemon (root):ambari
Adjusting ambari-server permissions and ownership...
Checking firewall status...
Checking JDK...
Do you want to change Oracle JDK [y/n] (n)? y
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
[3] Custom JDK
==============================================================================
Enter choice (1): 3
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.
Path to JAVA_HOME: /home/java/jre
Validating JDK on Ambari Server...done.
Checking GPL software agreement...
GPL License for LZO: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? n
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? y
Configuring database...
==============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
==============================================================================
Enter choice (3): 3
Hostname (localhost): 
Port (3306): 
Database name (ambari): 
Username (ambari): 
Enter Database Password (ambari): 
Configuring ambari database...
Configuring remote database connection properties...
WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Proceed with configuring remote database connection properties [y/n] (y)? n^Hy
input not recognized, please try again: 
Proceed with configuring remote database connection properties [y/n] (y)? y
Extracting system views...
ambari-admin-2.6.1.0.143.jar
...........
Adjusting ambari-server permissions and ownership...
Ambari Server &apos;setup&apos; completed successfully.
</code></pre><h3 id="启动ambari-server"><a href="#启动ambari-server" class="headerlink" title="启动ambari-server"></a>启动ambari-server</h3><pre><code>ambari-server start
</code></pre><blockquote>
<p>启动失败，查看日志：tail /var/log/ambari-server.log
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘ambari.metainfo’ doesn’t exist</p>
</blockquote>
<pre><code>导入表后再次启动
mysql -uroot -p ambari &lt; /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
</code></pre><ul>
<li><p>测试访问：node1:8080</p>
<p>  默认监听8080端口，如果失败，查看日志。使用默认账户admin/admin登录，界面如下</p>
<p>  <img src="https://i.imgur.com/Qw3fYfC.png" alt="管理界面"></p>
</li>
</ul>
<h2 id="创建数据平台"><a href="#创建数据平台" class="headerlink" title="创建数据平台"></a>创建数据平台</h2><h3 id="选择Launch-Install-Wizard"><a href="#选择Launch-Install-Wizard" class="headerlink" title="选择Launch Install Wizard"></a>选择Launch Install Wizard</h3><pre><code>![step0](https://i.imgur.com/ly0mo2a.png)
</code></pre><h3 id="配置为本地仓库"><a href="#配置为本地仓库" class="headerlink" title="配置为本地仓库"></a>配置为本地仓库</h3><pre><code>![配置本地仓库](https://i.imgur.com/AAJH4Tv.png)
</code></pre><h3 id="添加主机节点"><a href="#添加主机节点" class="headerlink" title="添加主机节点"></a>添加主机节点</h3><pre><code>    The user account used to install the Ambari Agent on the target host(s) via SSH. This user must be set up with passwordless SSH and sudo access on all the target host(s)
    添加主节点node1私钥id_rsa，必须能够免秘钥登录其他节点安装ambari agent
![配置节点](https://i.imgur.com/yY2LyF4.png)
</code></pre><h3 id="Confirm-Hosts"><a href="#Confirm-Hosts" class="headerlink" title="Confirm Hosts"></a>Confirm Hosts</h3><pre><code>在这一步可能碰见很多问题，执行之前一定要用tail -f实时查看日志，注意查看的是

<figure class="highlight plain"><figcaption><span>-f</span><a href="/var/log/ambari-server/ambari-server.log">link</a></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>

&gt; 错误示例一：

&gt; 查看openssl版本没有问题，更改所有ambari-client配置：在[security]单元下添加：force_https_protocol=PROTOCOL_TLSv1_2

<figure class="highlight plain"><figcaption><span>/etc/ambari-agent/conf/ambari-agent.ini</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>

    ERROR 2018-06-17 12:50:36,164 NetUtil.py:96 - EOF occurred in violation of protocol (_ssl.c:765)
    ERROR 2018-06-17 12:50:36,164 NetUtil.py:97 - SSLError: Failed to connect. Please check openssl library versions. 
    ......
    ......
    INFO 2018-06-17 12:50:35,295 main.py:437 - Connecting to Ambari server at https://node1:8440 (192.168.107.74)
    INFO 2018-06-17 12:50:35,295 NetUtil.py:70 - Connecting to https://node1:8440/ca
    ERROR 2018-06-17 12:50:36,164 NetUtil.py:96 - EOF occurred in violation of protocol (_ssl.c:765)
    ERROR 2018-06-17 12:50:36,164 NetUtil.py:97 - SSLError: Failed to connect. Please check openssl library versions. 
    Refer to: https://bugzilla.redhat.com/show_bug.cgi?id=1022468 for more details.

&gt; 错误示例二：

&gt; 不能创建文件夹，赋予权限，ambari-server在确认主机和分配服务均需要被操作

<figure class="highlight plain"><figcaption><span>-R ambari</span><a href="/var/run/ambari-server">link</a></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">	</span><br></pre></td></tr></table></figure>

    17 Jun 2018 12:20:23,259 ERROR [Thread-35] BSRunner:441 - java.io.FileNotFoundException: /var/run/ambari-server/bootstrap/1/node1.done (No such file or directory)
    17 Jun 2018 12:20:23,260  WARN [Thread-35] BSRunner:401 - File does not exist: /var/run/ambari-server/bootstrap/1/sshKey
    17 Jun 2018 12:41:20,217  INFO [Thread-37] BSRunner:189 - Kicking off the scheduler for polling on logs in /var/run/ambari-server/bootstrap/1

&gt; 错误示例三：

&gt; 注意主节点信任主机.ssh/known_hosts以及免秘钥登录除了客户机也必须要有自己，如果成功则如下：
</code></pre><p><img src="https://i.imgur.com/meXkLyF.png" alt="确认主机"></p>
<h3 id="选择服务"><a href="#选择服务" class="headerlink" title="选择服务"></a>选择服务</h3><blockquote>
<p>根据自己系统配置，建议可以一个个添加，比如先添加HDFS、YARN和MapReduce</p>
</blockquote>
<p><img src="https://i.imgur.com/6NR59vZ.png" alt="选择服务"></p>
<h3 id="assign-master"><a href="#assign-master" class="headerlink" title="assign master"></a>assign master</h3><p>相当于做集群配置
<img src="https://i.imgur.com/namV8ua.png" alt="指派master"></p>
<h3 id="主从分配"><a href="#主从分配" class="headerlink" title="主从分配"></a>主从分配</h3><p><img src="https://i.imgur.com/AmndrgO.png" alt="主从分配"></p>
<h3 id="自定义配置"><a href="#自定义配置" class="headerlink" title="自定义配置"></a>自定义配置</h3><p>红色的表示还需要进一步配置，数据库登录，根据提示来即可
之前已经添加了jdbc驱动，因此这里只要执行：
<figure class="highlight plain"><figcaption><span>setup --jdbc-db</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">```</span><br><span class="line"></span><br><span class="line">![自定义配置](https://i.imgur.com/ZnrSK6B.png)</span><br><span class="line"></span><br><span class="line">## 测试MapReduce</span><br><span class="line">**注意：root用户是不能操作hdfs文件系统的，当然可以更改hdfs-site.xml关闭权限验证，不过建议切换hdfs用户来操作**</span><br></pre></td></tr></table></figure></p>
<pre><code>su hdfs &amp;&amp; cd ~
</code></pre><p><code>`</code></p>
<ul>
<li><p>创建文件wc.txt，同时将文件上传到hdfs</p>
<pre><code>vi wc.txt
    hadoop hello world
    zk hello hadoop
    hbase hive
    zk spark
hadoop fs -mkdir /tmp/input
hadoop fs -put wc.txt /tmp/input
# 执行MapReduce，根据自己的版本和文件选择hdp的示例，或者使用自己的jar包
hadoop jar /usr/hdp/2.6.4.0-91/hadoop-mapreduce/hadoop-mapreduce-examples-2.7.3.2.6.4.0-91.jar wordcount /tmp/input/wc.txt /tmp/output
</code></pre></li>
<li><p>官方示例源码</p>
<p>  <a href="http://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#Source_Code" title="官方示例源码" target="_blank" rel="noopener">http://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html#Source_Code</a></p>
</li>
</ul>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/02/25/cryptic_interceptor/" rel="prev" title="使用拦截器进行数据加解密">
                使用拦截器进行数据加解密 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">yampery</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">6</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/yampery" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:1yampery@gmail.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#环境准备"><span class="nav-number">1.</span> <span class="nav-text">环境准备</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#准备节点"><span class="nav-number">1.1.</span> <span class="nav-text">准备节点</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#免秘钥登录"><span class="nav-number">1.2.</span> <span class="nav-text">免秘钥登录</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#关闭Selinux和防火墙"><span class="nav-number">1.3.</span> <span class="nav-text">关闭Selinux和防火墙</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#时间同步"><span class="nav-number">1.4.</span> <span class="nav-text">时间同步</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#安装nscd"><span class="nav-number">1.4.1.</span> <span class="nav-text">安装nscd</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装jdk"><span class="nav-number">1.5.</span> <span class="nav-text">安装jdk</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置本地仓库"><span class="nav-number">1.6.</span> <span class="nav-text">配置本地仓库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装ambar"><span class="nav-number">1.7.</span> <span class="nav-text">安装ambar</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#安装mariadb"><span class="nav-number">1.7.1.</span> <span class="nav-text">安装mariadb</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装ambari-server"><span class="nav-number">1.7.2.</span> <span class="nav-text">安装ambari-server</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#启动ambari-server"><span class="nav-number">1.7.3.</span> <span class="nav-text">启动ambari-server</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建数据平台"><span class="nav-number">1.8.</span> <span class="nav-text">创建数据平台</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#选择Launch-Install-Wizard"><span class="nav-number">1.8.1.</span> <span class="nav-text">选择Launch Install Wizard</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#配置为本地仓库"><span class="nav-number">1.8.2.</span> <span class="nav-text">配置为本地仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#添加主机节点"><span class="nav-number">1.8.3.</span> <span class="nav-text">添加主机节点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Confirm-Hosts"><span class="nav-number">1.8.4.</span> <span class="nav-text">Confirm Hosts</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#选择服务"><span class="nav-number">1.8.5.</span> <span class="nav-text">选择服务</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#assign-master"><span class="nav-number">1.8.6.</span> <span class="nav-text">assign master</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#主从分配"><span class="nav-number">1.8.7.</span> <span class="nav-text">主从分配</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#自定义配置"><span class="nav-number">1.8.8.</span> <span class="nav-text">自定义配置</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 &mdash; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yampery</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io" rel="external nofollow">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">NexT.Mist</a> v5.1.4</div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i> 本站访客数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      人次
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i> 本站总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      次
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("35rGUMRzp5wPN2jmmIUWeBNh-gzGzoHsz", "fmF6mJDmgl0FkqBKX8I2HiGF");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  

  

  

  

</body>
</html>
